REQUIRES: x86

RUN: lld-link /entry:main /subsystem:console /out:%t.exe \
RUN:   %p/Inputs/ret42.obj

RUN: lld-link /entry:main /subsystem:console /out:%t.exe \
RUN:   %p/Inputs/ret42.obj /failifmismatch:k1=v1 /failifmismatch:k2=v1

RUN: lld-link /entry:main /subsystem:console /out:%t.exe \
RUN:   %p/Inputs/ret42.obj /failifmismatch:k1=v1 /failifmismatch:k1=v1

RUN: env LLD_IN_TEST=1 not lld-link /entry:main /subsystem:console /out:%t.exe \
RUN:   %p/Inputs/ret42.obj /failifmismatch:k1=v1 /failifmismatch:k1=v2 2>&1 | FileCheck %s 

RUN: llc < %p/Inputs/failmismatch1.ll -mtriple x86_64-windows-msvc -filetype obj -o %t1.obj
RUN: llc < %p/Inputs/failmismatch2.ll -mtriple x86_64-windows-msvc -filetype obj -o %t2.obj
RUN: env LLD_IN_TEST=1 not lld-link %t1.obj %t2.obj 2>&1 | FileCheck %s -check-prefix OBJ

RUN: llvm-lib %t1.obj /out:%t.lib
RUN: env LLD_IN_TEST=1 not lld-link %t.lib %t2.obj 2>&1 | FileCheck %s -check-prefix LIB

CHECK: lld-link: error: /failifmismatch: mismatch detected for 'k1':
CHECK-NEXT: >>> cmd-line has value v1
CHECK-NEXT: >>> cmd-line has value v2

OBJ: lld-link: error: /failifmismatch: mismatch detected for 'TEST':
OBJ-NEXT: >>> {{.*}}failifmismatch.test.tmp1.obj has value 1
OBJ-NEXT: >>> {{.*}}failifmismatch.test.tmp2.obj has value 2

LIB: lld-link: error: /failifmismatch: mismatch detected for 'TEST':
LIB-NEXT: >>> {{.*}}failifmismatch.test.tmp2.obj has value 2
LIB-NEXT: >>> failifmismatch.test.tmp.lib(failifmismatch.test.tmp1.obj) has value 1
